Derive Rust Errors
This crate uses macros 1.1 to derive custom errors.
Getting Started
Add this crate to your dependencies section:-
[]
= "0.0.3"
Import it in your main.rs
or lib.rs
:-
extern crate derive-error;
Deriving errors is simple. Simply create an enum for your errors as suggested in the Rust book, add short descriptions for the enum variants using doc comments, throw in a #[derive(Debug, Error)]
and you are done. Here is the example in the book implemented using this library:-
This will derive implementations for Display
, Error
and From
. See the reql crate for a real world example of how to use this crate.